package operation;

import car.Cars;

import java.util.Scanner;

public class ExchangeVehicle implements IOperation {
    @Override
    public void work(Cars cars) {
        Scanner scanner = new Scanner(System.in);

        ShowVehicle showVehicle = new ShowVehicle();
        System.out.println("1. 轿车   2. 客车   3. 卡车");
        System.out.print("请输入你想要要更换的车的类型: ");
        int type = scanner.nextInt();
        showVehicle.show(cars.getList(type));
        System.out.print("请输入你想要更换的车的车牌号: ");
        String vehicleId = scanner.next();
        for (int i = 0; i < cars.getList(type).size(); i++) {
            if (cars.getList(type).get(i).getVehicleId().equals(vehicleId)) {
                System.out.println("更换成功!");
                System.out.println("现在你的车为: ");
                System.out.println(cars.getList(type).get(i));
            }
        }
    }
}
